package progress.exa35;

import java.io.*;

public class ExceptionStudy {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //classCastException();
//        arrayIndexOutOf();
//        nullPointException();
//        IoException1();
        classNotFoundException();
    }

    /**
     * 错误强转异常
     */
    public static void classCastException(){
        Object i  = "hehehe";
        Integer   n = (Integer) i;
    }

    /**
     * 数组越界访问异常
     */
    public static void arrayIndexOutOf(){
        int[] num = new int[2];
        num[4] = 5;
    }

    /**
     * 空指针异常
     */
    public static void nullPointException(){
        Object i = null;
        System.out.println(i.toString());
    }

    /**
     * IO异常
     * @throws IOException
     */
    public static void IoException1() throws IOException {
        File file = new File("noEx");
        InputStream inputStream = new FileInputStream(file);
        inputStream.read();
    }

    /**
     * 类加载异常
     * @throws ClassNotFoundException
     */
    public static void classNotFoundException() throws ClassNotFoundException {
        Class cl = Class.forName("java.fx.uif.jjj");
    }


}
